package net.zjitc;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TriMat {
    private int row;
    private int col;
    private List<Triple> list;

    public TriMat() {
        list = new ArrayList<Triple>();
    }



    public int[][] decompression() {
    int[][] temp=new int[row][col];

        Iterator<Triple> iterator=list.iterator();
        while (iterator.hasNext()){
            Triple triple=iterator.next();
            temp[triple.getRow()][triple.getCol()]=triple.getValue();
        }
        return temp;
    }

    public void createTriple(int[][] arr) {
        row = arr.length;
        col = arr[0].length;

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                if (arr[i][j] != 0) {
                    list.add(new Triple(i, j, arr[i][j]));
                }
            }
        }
    }

    public int getRow() {
        return row;
    }

    public int getCol() {
        return col;
    }

    public List<Triple> getList() {
        return list;
    }
}
